package cn.fufeiii.bt.common.config;

import lombok.extern.slf4j.Slf4j;
import org.springframework.aop.interceptor.AsyncUncaughtExceptionHandler;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.AsyncConfigurer;

import java.util.Arrays;

/**
 * 异步配置
 *
 * @author FuFei
 */
@Slf4j
@Configuration
public class AsyncConfig {

    @Bean
    public AsyncConfigurer exceptionLoggingAsyncConfigurer() {
        return new AsyncConfigurer() {
            @Override
            public AsyncUncaughtExceptionHandler getAsyncUncaughtExceptionHandler() {
                return (throwable, method, objects) -> log.warn("method:{}, parameter:{}", method.getName(), Arrays.toString(objects), throwable);
            }
        };
    }

}


